Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: DispatchQueue for synchronizing the session configuration and start operations #214

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

jimcase
Copy link

@jimcase jimcase commented Dec 13, 2024

This PR addresses synchronization issues reported on an Apple Developer Forum thread, where users encountered NSGenericException due to premature execution of AVCaptureSession.startRunning(). The problem arises from startRunning() being called before the completion of commitConfiguration(), especially noted in iOS 17 and some iOS 16 devices.

To resolve this, we introduce a serial DispatchQueue for managing AVCaptureSession operations in a FIFO (First In, First Out) sequence. Configuration tasks are encapsulated within a synchronous block to ensure complete setup before proceeding. Following this, startRunning() is scheduled asynchronously, guaranteeing it executes only after the configuration is fully committed. This approach not only prevents the NSGenericException by ensuring proper sequence of operations but also maintains high performance and responsiveness of the application.## Pull request checklist

Related PR fix(barcode-scanning): add delay before starting camera session #188

Please check if your PR fulfills the following requirements:

  • The changes have been tested successfully.
  • A changeset has been created (npm run changeset).
  • I have read and followed the pull request guidelines.

Copy link
Member

@robingenz robingenz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please create your PR against next and not against main.

.changeset/forty-avocados-allow.md Outdated Show resolved Hide resolved
}
}
}


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this empty line.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

jimcase and others added 2 commits December 18, 2024 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants